package com.rslai.base.tool.servertest.database.postgresql;

import java.io.Serializable;
import java.sql.SQLException;

import org.postgresql.util.PGobject;

public class LTree extends PGobject implements Serializable, Cloneable {
    private static final long serialVersionUID = 9137858405838675420L;
    String value;

    public LTree() {
        setType("ltree");
    }

    public LTree(Object value)
            throws SQLException {
        this();
        this.value = value.toString();
    }

    public void setValue(String value)
            throws SQLException {
        this.value = value;
    }

    public String getValue() {
        return this.value;
    }

    private static void writeValue(StringBuffer buf, Object o) {
        if (o == null) {
            buf.append("NULL");
            return;
        }
        String s = o.toString();
        buf.append('\'');
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ((c == '"') || (c == '\\')) {
                buf.append('\\');
            }
            buf.append(c);
        }
        buf.append('\'');
        buf.append("::ltree");
    }
}
